﻿using Loki.Utilities;
using log4net;

namespace GrindZonesRandomizer
{
    public class Logging
    {
        private readonly ILog _myLog = Logger.GetLoggerInstanceForType();

        /// <summary>
        /// Constructor, creates an instance of Logging
        /// </summary>
        public Logging()
        {
            
        }

        /// <summary>
        /// Use this to log as "Notice", so blank format
        /// </summary>
        /// <param name="msg"></param>
        public void Log(string msg)
        {
            _myLog.Notice(FormatMessage(msg));
        }

        /// <summary>
        /// This one require you to invoke a type of log
        /// </summary>
        /// <param name="type">alert, critical, debug, error, fatal, info, severe, trace, verbose, warn</param>
        /// <param name="msg"></param>
        public void Log(string type, string msg)
        {
            switch (type)
            {
                case "alert":
                    _myLog.Alert(FormatMessage(msg));
                    break;
                case "critical":
                    _myLog.Critical(FormatMessage(msg));
                    break;
                case "debug":
                    _myLog.Debug(FormatMessage(msg));
                    break;
                case "error":
                    _myLog.Error(FormatMessage(msg));
                    break;
                case "fatal":
                    _myLog.Fatal(FormatMessage(msg));
                    break;
                case "info":
                    _myLog.Info(FormatMessage(msg));
                    break;
                case "severe":
                    _myLog.Severe(FormatMessage(msg));
                    break;
                case "trace":
                    _myLog.Trace(FormatMessage(msg));
                    break;
                case "verbose":
                    _myLog.Verbose(FormatMessage(msg));
                    break;
                case "warn":
                    _myLog.Warn(FormatMessage(msg));
                    break;
            }
        }

        public string FormatMessage(string msg)
        {
            return "[GrindZonesRandomizer] " + msg;
        }
    }
}
